part of '../repository.dart';

const _kTrainingSettingsDataTrainingLexicalItemMaxCountKey = 'training_lexical_item_max_count';
const _kTrainingSettingsDataExerciseShuffleEnabledKey = 'exercise_shuffle_enabled';
const _kTrainingSettingsDataForgottenLexicalItemTrainingEnabledKey =
    'forgotten_lexical_item_training_enabled';
const _kTrainingSettingsDataTranslationSelectionExerciseEnabledKey =
    'translation_selection_exercise_enabled';
const _kTrainingSettingsDataAudioExerciseEnabledKey = 'audio_exercise_enabled';
const _kTrainingSettingsDataTypingExerciseEnabledKey = 'typing_exercise_enabled';

class _TrainingSettingsDataDto extends Equatable {
  const _TrainingSettingsDataDto._internal({
    required this.trainingLexicalItemMaxCount,
    required this.exerciseShuffleEnabled,
    required this.forgottenLexicalItemTrainingEnabled,
    required this.translationSelectionExerciseEnabled,
    required this.audioExerciseEnabled,
    required this.typingExerciseEnabled,
  });

  final int trainingLexicalItemMaxCount;
  final bool exerciseShuffleEnabled;
  final bool forgottenLexicalItemTrainingEnabled;
  final bool translationSelectionExerciseEnabled;
  final bool audioExerciseEnabled;
  final bool typingExerciseEnabled;

  @override
  List<Object?> get props {
    return [
      trainingLexicalItemMaxCount,
      exerciseShuffleEnabled,
      forgottenLexicalItemTrainingEnabled,
      translationSelectionExerciseEnabled,
      audioExerciseEnabled,
      typingExerciseEnabled,
    ];
  }

  factory _TrainingSettingsDataDto.fromJson(Map<String, dynamic> json) {
    return _TrainingSettingsDataDto._internal(
      trainingLexicalItemMaxCount: json[_kTrainingSettingsDataTrainingLexicalItemMaxCountKey],
      exerciseShuffleEnabled: json[_kTrainingSettingsDataExerciseShuffleEnabledKey],
      forgottenLexicalItemTrainingEnabled:
          json[_kTrainingSettingsDataForgottenLexicalItemTrainingEnabledKey],
      translationSelectionExerciseEnabled:
          json[_kTrainingSettingsDataTranslationSelectionExerciseEnabledKey],
      audioExerciseEnabled: json[_kTrainingSettingsDataAudioExerciseEnabledKey],
      typingExerciseEnabled: json[_kTrainingSettingsDataTypingExerciseEnabledKey],
    );
  }

  factory _TrainingSettingsDataDto.fromEntity(TrainingSettingsData trainingSettingsData) {
    return _TrainingSettingsDataDto._internal(
      trainingLexicalItemMaxCount: trainingSettingsData.trainingLexicalItemMaxCount,
      exerciseShuffleEnabled: trainingSettingsData.exerciseShuffleEnabled,
      forgottenLexicalItemTrainingEnabled: trainingSettingsData.forgottenLexicalItemTrainingEnabled,
      translationSelectionExerciseEnabled: trainingSettingsData.translationSelectionExerciseEnabled,
      audioExerciseEnabled: trainingSettingsData.audioExerciseEnabled,
      typingExerciseEnabled: trainingSettingsData.typingExerciseEnabled,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      _kTrainingSettingsDataTrainingLexicalItemMaxCountKey: trainingLexicalItemMaxCount,
      _kTrainingSettingsDataExerciseShuffleEnabledKey: exerciseShuffleEnabled,
      _kTrainingSettingsDataForgottenLexicalItemTrainingEnabledKey:
          forgottenLexicalItemTrainingEnabled,
      _kTrainingSettingsDataTranslationSelectionExerciseEnabledKey:
          translationSelectionExerciseEnabled,
      _kTrainingSettingsDataAudioExerciseEnabledKey: audioExerciseEnabled,
      _kTrainingSettingsDataTypingExerciseEnabledKey: typingExerciseEnabled,
    };
  }

  TrainingSettingsData toEntity() {
    return TrainingSettingsData(
      trainingLexicalItemMaxCount: trainingLexicalItemMaxCount,
      exerciseShuffleEnabled: exerciseShuffleEnabled,
      forgottenLexicalItemTrainingEnabled: forgottenLexicalItemTrainingEnabled,
      translationSelectionExerciseEnabled: translationSelectionExerciseEnabled,
      audioExerciseEnabled: audioExerciseEnabled,
      typingExerciseEnabled: typingExerciseEnabled,
    );
  }
}
